package main

import (
	pb "github.com/Rnben/echo/protos"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/reflection"
	"log"
	"net"
)

type echoServer struct{}

func (echo *echoServer) Echo(context.Context, *pb.EchoRequest) (*pb.EchoResponse, error) {
	return &pb.EchoResponse{Msg: "hello"}, nil

}

func main() {
	lis, err := net.Listen("tcp", "localhost:12345")
	if err != nil {
		log.Fatalf("Failed to listen: %v", err)
	}
	s := grpc.NewServer()
	pb.RegisterEchoServerServer(s, &echoServer{})
	reflection.Register(s)
	if err := s.Serve(lis); err != nil {
		log.Fatalf("Failed to echoServe: %v", err)
	}
}
